library(dplyr)
library(tidyverse)
library(ggplot2)
library(XML)
library(rjson)
library(jsonlite)
library(readr)
library(tm)
library(lubridate)
library(plotly)
library(htmlwidgets)
fish_2007 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=27832153-b03c-4008-9eb0-e33fa6165de8&limit=506")
fish_2008 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=2b65a199-4cdb-4bde-b342-2fb56a402139&limit=2136")
fish_2009 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=587478c8-584c-4d14-8de3-840130817960&limit=12528")
fish_2010 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=7d69ce36-7327-46d8-987b-7e41326d0024&limit=15995")
fish_2011 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=b58006b0-f099-457d-ac09-1b0504d95079&limit=21733")
fish_2012 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=723ffd91-29dd-4647-a881-562d4fc7cb24&limit=23049")
fish_2013 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=8cda8838-4f90-46ac-b9e7-182d90212a75&limit=23109")
fish_2014 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=1cb5555d-6dbb-4b95-88cc-72af90957748&limit=22706")
fish_2015 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=d8a607e9-8e6b-40fe-b161-dd4d2d36d713&limit=22921")
fish_2016 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=d967fa8f-e6b7-4d20-bf5c-2ce3b1ed19f3&limit=23722")
fish_2017 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=e92efbc2-09fc-4e35-84a3-9d75735c7096&limit=24125")
fish_2018 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=68d4c4a9-9db0-4c8a-b964-ef151c91daff&limit=24251")
fish_2019 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=14a87034-353c-43f2-b6db-9b0135a771b1&limit=24270")
fish_2020 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=8ef70d0f-cc2d-4df4-872e-b3297da44d0b&limit=22670")
fish_2021 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=022e9a4d-b184-495f-8dc2-734fb07e350c&limit=23604")
fish_2022 <- fromJSON("https://acikveri.bizizmir.com/tr/api/3/action/datastore_search?resource_id=fe1841f6-3da5-4b18-aa23-3079e211f755&limit=4151")
fish_2007<- as.data.frame(fish_2007[['result']][['records']])
fish_2008<- as.data.frame(fish_2008[['result']][['records']])
fish_2009<- as.data.frame(fish_2009[['result']][['records']])
fish_2010<- as.data.frame(fish_2010[['result']][['records']])
fish_2011<- as.data.frame(fish_2011[['result']][['records']])
fish_2012<- as.data.frame(fish_2012[['result']][['records']])
fish_2013<- as.data.frame(fish_2013[['result']][['records']])
fish_2014<- as.data.frame(fish_2014[['result']][['records']])
fish_2015<- as.data.frame(fish_2015[['result']][['records']])
fish_2016<- as.data.frame(fish_2016[['result']][['records']])
fish_2017<- as.data.frame(fish_2017[['result']][['records']])
fish_2018<- as.data.frame(fish_2018[['result']][['records']])
fish_2019<- as.data.frame(fish_2019[['result']][['records']])
fish_2020<- as.data.frame(fish_2020[['result']][['records']])
fish_2021<- as.data.frame(fish_2021[['result']][['records']])
fish_2022<- as.data.frame(fish_2022[['result']][['records']])
df_fish <- rbind(fish_2007, fish_2008, fish_2009, fish_2010, fish_2011, fish_2012, fish_2013, fish_2014, fish_2015, fish_2016, fish_2017, fish_2018, fish_2019, fish_2020, fish_2021, fish_2022)
df_fish$TARIH <- as.Date(df_fish$TARIH)
df_fish$ORTALAMA_UCRET <- as.numeric(sub(",", ".", df_fish$ORTALAMA_UCRET))
df_fish$ASGARI_UCRET <- as.numeric(sub(",", ".", df_fish$ASGARI_UCRET))
df_fish$AZAMI_UCRET <- as.numeric(sub(",", ".", df_fish$AZAMI_UCRET))
str(df_fish)
## 'data.frame': 291476 obs. of 8 variables:
## $ _id : int 1 2 3 4 5 6 7 8 9 10 ...
## $ TARIH : Date, format: "2007-01-20" "2007-01-20" ...
## $ MAL_TURU : chr "BALIK" "BALIK" "BALIK" "BALIK" ...
## $ MAL_ADI : chr "BAKALYAR(BÜYÜKBOY)" "LIDAKI (DENIZ)" "LÜFER (KÜÇÜK )" "ÇIPURA (DENIZ)" ...
## $ BIRIM : chr "KG" "KG" "KG" "KG" ...
## $ ASGARI_UCRET : num 4 4 3 8 4 3 2 3 2 3 ...
## $ AZAMI_UCRET : num 8 5 5 15 5 4 3 2 3 3 ...
## $ ORTALAMA_UCRET: num 6 4.5 4 11.5 4.5 3.5 2.5 2.5 2.5 3 ...
#View(df_fish)
df_fish %>% count(MAL_ADI)
## MAL_ADI n
## 1 AHTAPOT(DONUK) 81
## 2 AHTOPOT (DENIZ) 4047
## 3 AKYA (DENIZ) 2860
## 4 AKYA(DONUK) 9
## 5 ALABALIK ( TATLI ) 3533
## 6 ALABALIK(DONUK) 15
## 7 BAKALYAR(BÜYÜKBOY) 4256
## 8 BAKALYARO(KÜÇÜKBOY) 3873
## 9 BARBUN (TEKIR) 4297
## 10 BARBUN KAYA (DONUK) 10
## 11 BARBUN(DONUK) 21
## 12 BARBUN(KAYA) 4424
## 13 BÜLBÜL (DENIZ ) 2794
## 14 ÇAÇA(DENIZ) 65
## 15 ÇAPAK(TATLI) 1110
## 16 ÇEMEN ( DENIZ ) 8
## 17 ÇIMÇIM (DENIZ) 4110
## 18 ÇIMÇIM (DONUK) 503
## 19 ÇIPURA ( KÜLTÜR ) 4607
## 20 ÇIPURA (DENIZ) 4436
## 21 ÇUÇUNA 117
## 22 DENIZ PATLICANI 10
## 23 DIL 4507
## 24 DIL(CANGIDEZ) 2847
## 25 DONUK DIL 282
## 26 DONUK HAMSI 1846
## 27 DONUK PALAMUT 477
## 28 DONUK SARDALYA 1256
## 29 DONUK SOMON 3
## 30 DONUK TOMBIK 173
## 31 DONUK(KALAMAR) 1283
## 32 ESKINA(DENIZ) 422
## 33 FANGRI (DENIZ) 2881
## 34 FENER (DENIZ) 4109
## 35 FLOKARYA (DENIZ) 8
## 36 GELINCIK(DENIZ) 8
## 37 GÖÇMEN 11
## 38 GRANYOZ (DENIZ) 4020
## 39 GÜMÜS ( TATLI ) 105
## 40 HAMSI (DENIZ) 3853
## 41 HAMSI (YEM) 85
## 42 HANI(DENIZ) 21
## 43 HANOS ( DENIZ ) 2845
## 44 ISKANDIL (DENIZ) 3
## 45 ISKATARYA 4
## 46 ISKORPIT (DENIZ) 3988
## 47 ISPAROZ (DENIZ) 4022
## 48 ISPENDEK(DENIZ) 1213
## 49 ISTAKOZ (DENIZ) 2856
## 50 ISTAVRIT (DENIZ) 4310
## 51 ISTAVRIT (DONUK) 281
## 52 ISTAVRIT(SARI KANAT) 4258
## 53 ITHAL SOMON(TATLI) 3069
## 54 ITHAL USKUMRU(DONUK) 4147
## 55 IZMARIT (DENIZ) 4384
## 56 JAPON HAMSI 1858
## 57 KALAMAR (DENIZ) 4419
## 58 KALKAN (DENIZ) 1974
## 59 KAMIT (DONUK) 29
## 60 KAMIT(DENIZ) 3783
## 61 KARAGÖZ (DENIZ) 4123
## 62 KARIDES (DENIZ) 4374
## 63 KARIDES(DONUK) 120
## 64 KARIDES(JUNBO) 3
## 65 KEFAL ( TATLI ) 17
## 66 KEFAL (DENIZ) 4571
## 67 KEFAL (DONUK) 54
## 68 KELER(DENIZ) 10
## 69 KEREVIT ( DENIZ ) 1448
## 70 KILIÇ (DENIZ) 2568
## 71 KILIÇ (DONUK) 5
## 72 KIRLANGIÇ (DENIZ) 3645
## 73 KOFANA ( DENIZ ) 3037
## 74 KOLORIT(DENIZ) 1850
## 75 KOLYOZ (DENIZ) 4204
## 76 KOLYOZ (DONUK) 134
## 77 KÖPEK (DENIZ) 2802
## 78 KRAÇA ( DENIZ ) 3350
## 79 KRAÇA (DONUK) 312
## 80 KUPEZ (DENIZ) 4603
## 81 KUPEZ (DONUK) 248
## 82 LAHOZ (DENIZ) 3705
## 83 LAHOZ(ITHAL) 87
## 84 LEVREK ( KÜLTÜR ) 4617
## 85 LEVREK (DENIZ) 4306
## 86 LEVREK (TATLI ) 17
## 87 LIDAKI (DENIZ) 4497
## 88 LIDAKI (DONUK) 40
## 89 LIPSÖZ ( DENIZ ) 203
## 90 LOKUM(DENIZ) 1406
## 91 LÜFER ( DENIZ) 3700
## 92 LÜFER (KÜÇÜK ) 2415
## 93 LÜFER(DONUK) 143
## 94 LÜFER(IRI BOY) 1132
## 95 LÜFER[ KÜÇÜK BOY] 99
## 96 MARYA(DENIZ) 23
## 97 MASKO DENIZ 2937
## 98 MELANUR (DENIZ) 3521
## 99 MENEKSE(DENIZ) 18
## 100 MERCAN (BÜYÜKBOY) 4537
## 101 MERCAN(KÜÇÜK BOY) 4090
## 102 MEZGIT 1889
## 103 MEZGIT (DENIZ) 1567
## 104 MEZGIT (DONUK) 67
## 105 MIDYE 298
## 106 MIDYE DONUK 128
## 107 MINEKOP (DENIZ) 1080
## 108 MIRLAN(DENIZ) 20
## 109 MIRMIR (DENIZ) 4307
## 110 ÖKSÜZ(DENIZ) 139
## 111 ORFOZ (DENIZ) 1390
## 112 ORKINOZ (DENIZ) 927
## 113 PALAMUT-TORIK (DENIZ 3208
## 114 PALASKA(DENIZ) 277
## 115 PAPAGAN ( DENIZ ) 1614
## 116 PAPALINA ( DENIZ ) 152
## 117 PATLAKGÖZ(DENIZ) 19
## 118 PEYGAMBER (DENIZ) 4061
## 119 PISI ( DENIZ ) 1452
## 120 RINA(DENIZ) 47
## 121 RINGA 3
## 122 SARDALYA (DENIZ) 4546
## 123 SARDALYA (YEM) 104
## 124 SARGOZ(DENIZ) 3428
## 125 SARGOZ(INCE) 16
## 126 SARPA (DENIZ) 4295
## 127 SARPA (DONUK) 47
## 128 SAZAN ( TATLI ) 2432
## 129 SINARIT (DENIZ) 4126
## 130 SOKKAN(DENIZ) 1411
## 131 SOMON ( TATLI ) 2409
## 132 SÜBYE (DENIZ) 4080
## 133 SÜBYE (DONUK) 44
## 134 SUDAK ( TATLI ) 323
## 135 TEKIR (DONUK) 172
## 136 TEKIR(DENIZ) 4023
## 137 TIRSI (DENIZ) 4573
## 138 TIRSI (DONUK) 304
## 139 TOMBIK(DENIZ) 2821
## 140 TRANÇA (DENIZ) 3175
## 141 TURNA ( TATLI ) 90
## 142 TURNA (DENIZ) 3680
## 143 USKUMRU (DENIZ) 3146
## 144 USKUMRU (DONUK) 60
## 145 VATOZ (DENIZ) 2336
## 146 YABANI KALAMAR 3804
## 147 YAYIN ( TATLI ) 639
## 148 YAZILIORKINOS(DENIZ) 2591
## 149 YAZILIORKINOZ(DONUK) 28
## 150 YENGEÇ (DENIZ) 1026
## 151 YILAN ( TATLI ) 2287
## 152 ZARGANA (DENIZ) 3018
df_fish <- df_fish %>%
mutate(year = lubridate::year(TARIH),
month = lubridate::month(TARIH),
day = lubridate::day(TARIH))
head(df_fish)
## _id TARIH MAL_TURU MAL_ADI BIRIM ASGARI_UCRET AZAMI_UCRET
## 1 1 2007-01-20 BALIK BAKALYAR(BÜYÜKBOY) KG 4 8
## 2 2 2007-01-20 BALIK LIDAKI (DENIZ) KG 4 5
## 3 3 2007-01-20 BALIK LÜFER (KÜÇÜK ) KG 3 5
## 4 4 2007-01-20 BALIK ÇIPURA (DENIZ) KG 8 15
## 5 5 2007-01-20 BALIK GRANYOZ (DENIZ) KG 4 5
## 6 6 2007-01-20 BALIK ISKANDIL (DENIZ) KG 3 4
## ORTALAMA_UCRET year month day
## 1 6.0 2007 1 20
## 2 4.5 2007 1 20
## 3 4.0 2007 1 20
## 4 11.5 2007 1 20
## 5 4.5 2007 1 20
## 6 3.5 2007 1 20
df_fish_a <- df_fish %>% group_by(MAL_ADI, year)%>% summarize(m = mean(ORTALAMA_UCRET))
df_fish_b <- df_fish %>% group_by(MAL_ADI, year) %>% filter(MAL_ADI =="AHTAPOT(DONUK)") %>% summarize(m = mean(ORTALAMA_UCRET))
df_fish_c <- df_fish%>% group_by(MAL_TURU, year)%>% summarize(m = mean(ORTALAMA_UCRET))
df_fish_d <- df_fish %>% group_by(MAL_TURU, year, month)%>% summarize(m = mean(ORTALAMA_UCRET))
df_fish_a
## # A tibble: 1,889 x 3
## # Groups: MAL_ADI [152]
## MAL_ADI year m
## <chr> <dbl> <dbl>
## 1 AHTAPOT(DONUK) 2011 10
## 2 AHTAPOT(DONUK) 2012 8.75
## 3 AHTAPOT(DONUK) 2014 11.7
## 4 AHTAPOT(DONUK) 2015 15.2
## 5 AHTAPOT(DONUK) 2016 17.2
## 6 AHTAPOT(DONUK) 2017 17.5
## 7 AHTAPOT(DONUK) 2018 31.6
## 8 AHTAPOT(DONUK) 2019 46.4
## 9 AHTAPOT(DONUK) 2020 46.7
## 10 AHTAPOT(DONUK) 2021 60
## # ... with 1,879 more rows
df_fish_b
## # A tibble: 10 x 3
## # Groups: MAL_ADI [1]
## MAL_ADI year m
## <chr> <dbl> <dbl>
## 1 AHTAPOT(DONUK) 2011 10
## 2 AHTAPOT(DONUK) 2012 8.75
## 3 AHTAPOT(DONUK) 2014 11.7
## 4 AHTAPOT(DONUK) 2015 15.2
## 5 AHTAPOT(DONUK) 2016 17.2
## 6 AHTAPOT(DONUK) 2017 17.5
## 7 AHTAPOT(DONUK) 2018 31.6
## 8 AHTAPOT(DONUK) 2019 46.4
## 9 AHTAPOT(DONUK) 2020 46.7
## 10 AHTAPOT(DONUK) 2021 60
df_fish_c
## # A tibble: 64 x 3
## # Groups: MAL_TURU [4]
## MAL_TURU year m
## <chr> <dbl> <dbl>
## 1 BALIK 2007 6.81
## 2 BALIK 2008 NA
## 3 BALIK 2009 11.9
## 4 BALIK 2010 13.3
## 5 BALIK 2011 15.3
## 6 BALIK 2012 15.7
## 7 BALIK 2013 16.2
## 8 BALIK 2014 18.0
## 9 BALIK 2015 NA
## 10 BALIK 2016 18.9
## # ... with 54 more rows
df_fish_d
## # A tibble: 680 x 4
## # Groups: MAL_TURU, year [64]
## MAL_TURU year month m
## <chr> <dbl> <dbl> <dbl>
## 1 BALIK 2007 1 6.63
## 2 BALIK 2007 2 7.74
## 3 BALIK 2008 1 NA
## 4 BALIK 2008 2 16.8
## 5 BALIK 2008 3 16.8
## 6 BALIK 2008 4 16.8
## 7 BALIK 2008 5 16.8
## 8 BALIK 2008 6 16.1
## 9 BALIK 2008 7 14.8
## 10 BALIK 2008 9 11.3
## # ... with 670 more rows
f3 <- plot_ly(df_fish_d, x = ~month, y = ~m) %>%
add_lines(color = ~ordered(year))
saveWidget(f3, "f3.html", selfcontained = F, libdir = "lib")
f2 <- plot_ly(df_fish_c, x = ~year, y = ~m) %>%
add_lines(color = ~ordered(MAL_TURU))
saveWidget(f2, "f2.html", selfcontained = F, libdir = "lib")